<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    //执行顺序 必须先等异步执行完毕
    function testAwait() {
      return new Promise((resolve) => {
        setTimeout(function () {
          console.log('testAwait')
          resolve()
        }, 1000)
      })
    }

    async function helloAsync() {
      await testAwait()
      console.log('helloAsync')
    }
    helloAsync()

    //强行把不是异步的代码变成异步代码
    async function a() {
      await 1
      console.log('1')
      console.log('2')
    }
    a()
    console.log('3')
  </script>
</html>
